import QRequest from '@/service/index';
import { generateNameToLevel } from '@/config/constant';
import type { AuxiliaryDataParams, AuxiliaryDataResponse, AddAuxiliaryData } from './model/type';

/**
 * @: 获取辅助资源
 * @param {AuxiliaryDataParams} params
 * @return {*}
 */
export const doGetAuxiliaryList = (params: AuxiliaryDataParams) => {
    return QRequest.get<AuxiliaryDataResponse>(`/auxiliaryData/pageAuxiliaryData`, {
        params,
        headers: {
            loadingTarget: `#${generateNameToLevel('2')}`
        }
    });
};

/**
 * @: 新增辅助资源
 * @param {AddAuxiliaryData} data
 * @return {*}
 */
export const doAddAuxiliary = (data: AddAuxiliaryData[]) => {
    return QRequest.post(`/auxiliaryData/save`, data, {
        headers: {
            hideLoading: 1
        }
    });
};

/**
 * @: 编辑辅助资源
 * @param {AddAuxiliaryData} data
 * @return {*}
 */
export const doUpdateAuxiliary = (data: AddAuxiliaryData) => {
    return QRequest.put(`/auxiliaryData/update`, data, {
        headers: {
            hideLoading: 1
        }
    });
};

/**
 * @: 删除辅助资源
 * @param {number} params
 * @return {*}
 */
export const doDelAuxiliaryList = (data: number[]) => {
    return QRequest.delete(`/auxiliaryData/delete`, {
        data,
        headers: {
            hideLoading: 1
        }
    });
};
